package com.mori.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p> 配置解决三个问题
 * 硬编码
 * 配置文件
 * DB 配置表
 *
 * </p>
 *
 * @author mori
 * @since 10/18/2019 4:50 PM
 */
@SpringBootApplication
@EnableDiscoveryClient
public class ConfigApplication {

    public static void main(String[] args) {
        SpringApplication.run(ConfigApplication.class, args);
    }
}

@Slf4j
@RestController
@RefreshScope
class TestController {

    @Value(value = "${connectTimeoutInMills}")
    private String connectTimeoutInMills;

    @GetMapping("/get")
    public String test() {
        return "Return : " + connectTimeoutInMills;
    }


    @GetMapping(value = "/hello")
    public String hello() {
        return "Hello Sentinel";
    }

}


